#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int N = 210;
int cnt[N];
vector<int> e[N];

void solve() {
	int n, m; cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		cnt[i] = 0;
		e[i].clear();
	}
	while (m--) {
		int u, v; cin >> u >> v;
		e[u].push_back(v); cnt[u]++;
		e[v].push_back(u); cnt[v]++;
	}
	ll ans = 0;
	set<int> st;
	for (int i = 1; i <= n; i++) {
		if (cnt[i] == 1) {
			ans++;
			st.insert(e[i][0]);
		}
	}
	cout << st.size() << " " << ans / st.size() << endl;
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t; cin >> t;
	while (t--) {
		solve();
	}
	return 0;
}